package com.key.service.impl;

import com.key.common.vo.DepartmentAndCompanyVO;
import com.key.entity.Company;
import com.key.entity.Department;
import com.key.mapper.OrganizationalStructureMapper;
import com.key.service.OrganizationalStructureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：朕
 * @Package：com.key.service.impl
 * @Project：ams_system
 * @name：OrganizationalStructureServiceImpl
 * @Date：2023/2/22 16:16
 * @Filename：OrganizationalStructureServiceImpl
 */
@Service
public class OrganizationalStructureServiceImpl implements OrganizationalStructureService {

    @Autowired
    private OrganizationalStructureMapper organizationalStructureMapper;

    /**
     * 显示公司
     * @return
     */
    @Override
    public List<Company> findCompany() {
        List<Company> companies = organizationalStructureMapper.findCompany();
        return companies;
    }

    /**
     * 增加公司
     * @param company
     * @return
     */
    @Override
    public boolean addCompany(Company company) {
        boolean o = organizationalStructureMapper.addCompany(company);
        if(o==true){
            return  true;
        }else{
            return  false;
        }
    }

    /**
     * 删除公司
     * @param id
     * @return
     */
    @Override
    public boolean deleteCompany(int id) {
        boolean o = organizationalStructureMapper.deleteCompany(id);
        if(o==true){
            return  true;
        }else{
            return  false;
        }
    }

    /**
     * 根据公司Id查询公司信息
     * @param id
     * @return
     */
    @Override
    public List<Company> findCompanyById(int id) {
        List<Company> companies = organizationalStructureMapper.findCompanyById(id);
        return companies;
    }

    /**
     * 修改公司信息
     * @param company
     * @return
     */
    @Override
    public boolean updateCompany(Company company) {
        boolean o = organizationalStructureMapper.updateCompany(company);
        if(o==true){
            return  true;
        }else{
            return  false;
        }
    }

    /**
     * 显示部门
     * @return
     */
    @Override
    public List<Department> findDepartment() {
        List<Department> departments = organizationalStructureMapper.findDepartment();
        return departments;
    }

    /**
     * 增加部门
     * @param department
     * @return
     */
    @Override
    public boolean addDepartment(Department department) {
        boolean o = organizationalStructureMapper.addDepartment(department);
        if(o==true){
            return  true;
        }else{
            return  false;
        }
    }

    /**
     * 删除部门
     * @param id
     * @return
     */
    @Override
    public boolean deleteDepartment(int id) {
        boolean o = organizationalStructureMapper.deleteDepartment(id);
        if(o==true){
            return  true;
        }else{
            return  false;
        }
    }

    /**
     * 根据部门编码查询部门信息
     * @param id
     * @return
     */
    @Override
    public List<Department> findDepartmentById(int id) {
        List<Department> departments = organizationalStructureMapper.findDepartmentById(id);
        return departments;
    }

    /**
     * 修改部门信息
     * @param department
     * @return
     */
    @Override
    public boolean updateDepartment(Department department) {
        boolean o = organizationalStructureMapper.updateDepartment(department);
        if(o==true){
            return  true;
        }else{
            return  false;
        }
    }

    /**
     * 显示公司和对应的部门
     * @return
     */
    @Override
    public List<DepartmentAndCompanyVO> findCompanyAndDepartment() {
        List<DepartmentAndCompanyVO> objects = organizationalStructureMapper.findCompanyAndDepartment();
        return objects;
    }

}
